<!-- 投标信息 -->
<template>
	<view>
		<view class="list_box" @touchstart="touchShow = false" @click="touchShow =false" @touchmove="touchShow = false">
			<view class="oyher_top" id="basic">投标信息</view>
			<view class="basic_box" id="basic">
				<view class="label">
					<view class="label_title">档案编号</view>
					<view class="label_info">{{ model.finalNo?model.finalNo:'--' }}</view>
				</view>
				<view class="label">
					<view class="label_title">经办部门</view>
					<view class="label_info">{{ model.proposerDeptId_dictText?model.proposerDeptId_dictText:'--' }}</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">经办人</view>
						<view class="label_info">{{model.proposer_dictText?model.proposer_dictText:'--'}}</view>
					</view>
					<view class="label">
						<view class="label_title">日期</view>
						<view class="label_info">{{model.createTime?model.createTime:'--'}}</view>
					</view>
				</view>
			</view>
			
			<view class="other_box"></view>
			<view class="oyher_top">
				基本信息
			</view>
			<view class="basic_box">
				<view class="label" v-if="model.applyType == '2'">
					<view class="label_title">投标编号</view>
					<view class="label_info">{{ model.tenderFinalCode }}</view>
				</view>
				<view class="label">
					<view class="label_title">项目名称</view>
					<view class="label_num" @click="onClickProjectName(model)">{{ model.projectName }}</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">项目承接人</view>
						<view class="label_info">{{model.undertaker_dictText}}</view>
					</view>
					<view class="label">
						<view class="label_title">业绩归属年度</view>
						<view class="label_info">{{model.year_dictText}}</view>
					</view>
				</view>
				<view class="label">
					<view class="label_title">经营团队</view>
					<view class="label_info">{{model.businessTeam_dictText}}</view>
				</view>
				<view class="label">
					<view class="label_title">项目所在地址</view>
					<view class="label_info">{{model.address}}</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">报名截止时间</view>
						<view class="label_info">{{model.entriesEndDate}}</view>
					</view>
					<view class="label">
						<view class="label_title">投标截止时间</view>
						<view class="label_info">{{model.tenderEndDate}}</view>
					</view>
				</view>
				<view class="label">
					<view class="label_title">业主单位</view>
					<view class="label_info">{{model.ownerUnit_dictText}}</view>
				</view>
				
				<view class="flex_box">
					<view class="label">
						<view class="label_title">业主联系人</view>
						<view class="label_info">{{model.ownerLinkman_dictText}}</view>
					</view>
					<view class="label">
						<view class="label_title">业主联系方式</view>
						<view class="label_num" @click="onPhone(model.ownerTel)">{{model.ownerTel}}</view>
					</view>
				</view>
				
				<view class="flex_box">
					<view class="label">
						<view class="label_title">招标方式</view>
						<view class="label_info">{{model.biddingMethod_dictText}}</view>
					</view>
					<view class="label">
						<view class="label_title">招标控制价(元)</view>
						<view class="label_info">{{model.controlPrice}}</view>
					</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">标书费(元)</view>
						<view class="label_info">{{model.entryFee}}</view>
					</view>
					<view class="label">
						<view class="label_title">投标保证金(元)</view>
						<view class="label_info">{{model.tenderBond}}</view>
					</view>
				</view>
				<view class="label">
					<view class="label_title">项目公示信息</view>
					<view class="label_info">{{model.projectPublicity}}</view>
				</view>
				<view class="label">
					<view class="label_title">投标内容概要</view>
					<view class="label_info">{{model.tenderContent}}</view>
				</view>
				<view class="label">
					<view class="label_title">招标文件</view>
					<view class="label_info"><file-list :fileList="model.tenderFile"></file-list></view>
				</view>
			</view>
			
			<view class="other_box"></view>
			<view class="oyher_top">
				投标单位信息
			</view>
			<view class="basic_box">
				<view class="label">
					<view class="label_title">投标部门</view>
					<view class="label_info">{{ model.tenderDept_dictText }}</view>
				</view>
				<view class="label">
					<view class="label_title">投标单位</view>
					<view class="label_info">{{ model.tenderUnit_dictText }}</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">投标编制人</view>
						<view class="label_info">{{model.tenderPerson_dictText}}</view>
					</view>
					<view class="label">
						<view class="label_title">是否需要协调</view>
						<view class="label_info">{{model.needHelp_dictText}}</view>
					</view>
				</view>
				<view class="label" v-if="model.needHelp && model.needHelp == '1'">
					<view class="label_title">协同人员(多选)</view>
					<view class="label_info">{{model.helperIds_dictText}}</view>
				</view>
				
				<view class="label">
					<view class="label_title">备注</view>
					<view class="label_info">{{model.remarks}}</view>
				</view>
			</view>
			
			<view class="other_box"></view>
			<view class="oyher_top">业务分类</view>
			<tenderInformationBusinessItem :dataSource="dataSource"></tenderInformationBusinessItem>
			
			<view class="other_box"></view>
			<view class="oyher_top">投标文件信息</view>
			<tenderDocumentInformationItem :dataSource="fileDataSource"></tenderDocumentInformationItem>
			<view class="other_box"></view>
			<view class="oyher_top">投标结果信息</view>
			<tenderResultInforamtionItem :dataSource="resDataSource"></tenderResultInforamtionItem>
		</view>
		
		<!-- 权限告知弹窗 -->
		<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" permissionID="CALL_PHONE"></yk-authpup>
	</view>
</template>

<script>
	import http from '@/utils/request/index.js'
	import specialHttp from '@/utils/request/specialIndex' // 特殊请求方式，直接返回res
	import address from '@/utils/address.js'
	import fileList from '@/pages/synergy/components/fileList.vue'
	import tenderInformationBusinessItem from './tenderInformationBusinessItem.vue'
	import tenderDocumentInformationItem from './tenderDocumentInformationItem.vue'
	import tenderResultInforamtionItem from './tenderResultInforamtionItem.vue'
	import ykAuthpup from "@/components/yk-authpup/yk-authpup";
	export default {
		props: {
			projectId: {
				type: [String, Number],
				default: '',
			}
		},
		components: {
			fileList,
			tenderInformationBusinessItem, // 业务分类
			tenderDocumentInformationItem, // 投标文件信息
			tenderResultInforamtionItem, // 投标结果信息
			ykAuthpup
		},
		watch: {
			projectId: {
				handler (val) {
					if (val) {
						this.loadDataByProjectId(val)	// 获取详情
					}
				},
				immediate: true
			}
		},
		data() {
			return {
				model: {},
				address,
				dataSource: [],
				unitDataSource: [],
				fileDataSource: [], // 投标文件信息列表
				resDataSource: [],
				phone: ''
			}
		},
		methods: {
			
			// 根据项目查看投标信息
			async loadDataByProjectId(val) {
				await this.ininClearData();
				http.get('/api/erp/omc/tender/erpOmcTenderFinal/queryTenderDataByProjectId', { projectId: val }).then(async (res) => {
					if (res.success) {
						if (res.result.length > 0) {
							this.edit(res.result[0])
						}
					}
				})
			},
			async edit (record) {
				this.model = await Object.assign({}, record);
				this.model.address = this.getAddress(record.projectAddress) + record.detailedAddress
				if (this.model.id) {
					// 业务分类
					http.get('/api/erp/omc/tender/erpOmcTenderServiceFinal/queryTenderServiceListByTenderId', { id: this.model.id }).then(async (res) => {
						if (res.success) {
							this.dataSource = res.result.records || res.result
						}
					}),
					http.get('/api/erp/omc/tender/erpOmcTenderUnitFinal/queryTenderListByTenderId', { id: this.model.id }).then(async (res) => {
						if (res.success) {
							this.unitDataSource = res.result.records || res.result
						}
					}),
					http.get('/api/erp/omc/tender/erpOmcTenderFileFinal/listbytenderid', { tenderId: this.model.id }).then(async (res) => {
						if (res.success) {
							this.fileDataSource = res.result || res.result.records
						}
					}),
					http.get('/api/erp/omc/tender/erpOmcTenderResultFinal/listbytenderid', { tenderId: this.model.id }).then(async (res) => {
						if (res.success) {
							this.resDataSource = res.result || res.result.records
						}
					})
				}
			},
			ininClearData() {
				this.dataSource = []
				this.unitDataSource = []
				this.fileDataSource = []
				this.resDataSource = []
				this.model = {}
			},
			// 地址显示
			getAddress(areaCode) {
			  var arr = areaCode.split(',')
			  var addressDetail = ''
			  this.address.map((value) => {
			    if (arr[0] && value.code == arr[0]) {
			      addressDetail = value.name
			      value.children.map((val) => {
			        if (arr[1] && val.code == arr[1]) {
			          addressDetail = addressDetail + val.name
			          val.children.map((item) => {
			            if (arr[2] && item.code == arr[2]) {
			              addressDetail = addressDetail + item.name
			            }
			          })
			        }
			      })
			    }
			  })
			  return addressDetail
			},
			
			// 点击项目名称
			onClickProjectName (item) {
				uni.redirectTo({
					url: '/pages/reportFilesList/erpProjectReportListDetail?id=' + item.prepareProjectId
				})
			},
			
			openAuth(){
					this.$refs['authpup'].open() //调起自定义权限目的弹框,具体可看示例里面很详细
			},
			//用户授权权限后的回调
			changeAuth(){
				let _this = this
				uni.makePhoneCall({
					phoneNumber: this.phone,
					fail() {
						uni.showToast({
							title: '拨打电话失败',
							icon: 'none'
						})
					}
				})
			},
			onPhone (value) {
				// #ifdef APP-PLUS
				this.phone = value
				this.openAuth()
				// #endif
				// #ifndef APP-PLUS
				uni.showToast({
					title: '暂无此功能',
					icon: 'none'
				})
				// #endif
			},
		}
	}
</script>

<style lang="less" scoped>
@import url("@/assets/projectStyle.less");
</style>